home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 5.2 KB | 180 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Content.cpp
- // Release Version: $ ODF 1 $
- //
- // Author: M.Boetcher
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Embed.hpp"
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef PROXY_H
- #include "Proxy.h"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- //========================================================================================
- // Runtime information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfembed
- #endif
-
- FW_DEFINE_AUTO(CEmbedContent)
-
- //========================================================================================
- // CLASS CEmbedContent
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CEmbedContent constructor
- //----------------------------------------------------------------------------------------
-
- CEmbedContent::CEmbedContent(Environment* ev, CEmbedPart* part)
- : FW_CEmbeddingContent(ev, part),
- fEmbedPart(part),
- fProxy(NULL)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedContent destructor
- //----------------------------------------------------------------------------------------
-
- CEmbedContent::~CEmbedContent()
- {
- delete fProxy;
- fProxy = NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedContent::Externalize
- //----------------------------------------------------------------------------------------
-
- void CEmbedContent::Externalize(Environment* ev,
- ODStorageUnit* storageUnit,
- FW_EStorageKinds storageKind,
- FW_CCloneInfo* cloneInfo)
- {
- // ----- Create an archive -----
- FW_PStorageUnitSink suSink(ev, storageUnit, kODPropContents, fEmbedPart->GetPartKind(ev));
- FW_CWritableStream archive(suSink);
-
- // ----- Write number of embedded parts -----
- unsigned long count = (fProxy ? 1 : 0);
- archive << count;
-
- // ----- Write embedded part -----
- if (fProxy)
- fProxy->Externalize(ev, suSink->GetStorageUnitView(ev), cloneInfo);
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedContent::Internalize
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CEmbedContent::Internalize(Environment* ev,
- ODStorageUnit* storageUnit,
- FW_EStorageKinds storageKind,
- FW_CCloneInfo* cloneInfo)
- {
- if (!storageUnit->Exists(ev, kODPropContents, fEmbedPart->GetPartKind(ev), 0))
- return false;
-
- // ----- Create an archive -----
- FW_PStorageUnitSink suSink(ev, storageUnit, kODPropContents, fEmbedPart->GetPartKind(ev));
- FW_PBufferedSink sink(ev, suSink);
- FW_CReadableStream archive(sink);
-
- // ----- Read number of embedded parts -----
- unsigned long count;
- archive >> count;
-
- // ----- Read embedded part, if any -----
- if (count == 1)
- {
- fProxy = new CEmbedProxy(ev, fEmbedPart, fEmbedPart->GetPresentation());
- fProxy->Internalize(ev, suSink->GetStorageUnitView(ev), cloneInfo);
- }
-
- if (storageKind != FW_kPartStorage)
- fEmbedPart->Changed(ev);
-
- return true;
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedContent::SingleEmbeddedFrameInternalized
- //----------------------------------------------------------------------------------------
-
- void CEmbedContent::SingleEmbeddedFrameInternalized(Environment* ev,
- FW_CEmbeddingFrame* scopeFrame,
- ODPart* odEmbeddedPart,
- ODFrame* odEmbeddedFrame,
- ODShape* suggestedShape,
- ODTypeToken viewType)
- {
- // ----- Detach existing proxy, if any -----
- if (fProxy)
- {
- fProxy->SetSelectState(ev, false);
- fProxy->DetachEmbeddedFrames(ev);
- }
-
- // ----- Calculate the frame shape -----
- FW_CAcquiredODShape aqFrameShape = ((CEmbedFrame*)scopeFrame)->MakeFrameShape(ev);
-
- // ----- Create the proxy -----
- CEmbedProxy* newProxy = new CEmbedProxy(ev, fEmbedPart, scopeFrame->GetPresentation(ev));
-
- // ----- Embed the Part/Frame -----
- scopeFrame->GetPresentation(ev)->Embed(ev,
- odEmbeddedPart,
- odEmbeddedFrame,
- kODFrameObject,
- newProxy,
- aqFrameShape,
- viewType,
- NULL, // no presentation
- 0, // group id
- FALSE, // is Overlaid
- false); // sub-frame?
-
- // ----- Set the proxy -----
- fProxy = newProxy;
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedContent::IsDataOnlyOneProxy
- //----------------------------------------------------------------------------------------
-
- FW_MProxy* CEmbedContent::IsDataOnlyOneProxy(Environment* ev) const
- {
- return fProxy;
- }
-